package com.ayu.shortlink.engine.controller;

import com.ayu.shortlink.engine.common.convention.result.Result;
import com.ayu.shortlink.engine.common.convention.result.Results;
import com.ayu.shortlink.engine.dto.req.UserRedeemCouponReqDTO;
import com.ayu.shortlink.engine.service.UserCouponService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户优惠券控制器
 */
@RestController
@RequiredArgsConstructor
public class UserCouponController {
    private final UserCouponService userCouponService;

    /**
     * 用户抢购优惠券
     */
    @PostMapping("/api/short-link/engine/v1/user-coupon/redeem")
    public Result<Void> redeemCoupon(@RequestBody UserRedeemCouponReqDTO requestParam){
        userCouponService.redeemCoupon(requestParam);
        return Results.success();
    }

    /**
     * 用户抢购优惠券(v2)
     */
    @PostMapping("/api/short-link/engine/v2/user-coupon/redeem")
    public Result<Void> redeemCoupon2(@RequestBody UserRedeemCouponReqDTO requestParam){
        userCouponService.redeemCoupon2(requestParam);
        return Results.success();
    }

    /**
     * 用户抢购优惠券(v3)
     */
    @PostMapping("/api/short-link/engine/v3/user-coupon/redeem")
    public Result<Void> redeemCoupon3(@RequestBody UserRedeemCouponReqDTO requestParam){
        userCouponService.redeemCoupon3(requestParam);
        return Results.success();
    }

    /**
     * 用户抢购优惠券(v4)
     */
    @PostMapping("/api/short-link/engine/v4/user-coupon/redeem")
    public Result<Void> redeemCoupon4(@RequestBody UserRedeemCouponReqDTO requestParam){
        userCouponService.redeemCoupon4(requestParam);
        return Results.success();
    }

    /**
     * 用户抢购优惠券(v5)
     */
    @PostMapping("/api/short-link/engine/v5/user-coupon/redeem")
    public Result<Void> redeemCoupon5(@RequestBody UserRedeemCouponReqDTO requestParam){
        userCouponService.redeemCoupon5(requestParam);
        return Results.success();
    }
}
